package com.example.SpringBoot_demo.service.impl;

import com.example.SpringBoot_demo.bean.BlackUser;
import com.example.SpringBoot_demo.bean.User;
import com.example.SpringBoot_demo.mapper.BlacklistMapper;
import com.example.SpringBoot_demo.service.BlackListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlackListServiceImpl implements BlackListService {

    @Autowired
    private BlacklistMapper blacklistMapper;

    @Override
    public List<BlackUser> viewBlackList(int page, int numb) {
        return blacklistMapper.viewBlackList(page, numb);
    }

    @Override
    public List<BlackUser> searchBlackUser(String id,String name) {
        return blacklistMapper.searchBlackUser(id,name);
    }

    @Override
    public void deleteBlackUser(String id) {
        blacklistMapper.deleteBlackUser(id);
        blacklistMapper.updateBlackList(id,"0");
        //return blacklistMapper.viewBlackList(page, numb);
    }

    @Override
    public List<User> viewUserList(int page, int numb) {
        List<User> UserList=blacklistMapper.viewUserList(page, numb);
//        System.out.println(blackUserList.get(0).getUserid());
//        System.out.println(blackUserList.get(0).getUsername());
        return UserList;
    }

    @Override
    public void addBlackUser(String userid, String username) {
        blacklistMapper.addBlackUser(userid,username);
        blacklistMapper.updateBlackList(userid,"1");
    }

    @Override
    public int countPage(String listname) {
        //System.out.println(listname);
        return blacklistMapper.countPage(listname);
    }
    @Override
    public List<User> searchUser(String id,String name) {
        return blacklistMapper.searchUser(id,name);
    }
}
